/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Dosen;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author advent
 */
public class DosenTableModel extends AbstractTableModel{
 private List<Dosen> dosen = new ArrayList<Dosen>();

    public DosenTableModel(List <Dosen> dosen) {
        this.dosen = dosen;
    }

    public void delete(int row){
        dosen.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void update(int row, Dosen kat) {
       dosen.set(row, kat);
       fireTableRowsUpdated(row, row);
    }


    public int getRowCount() {
        return dosen.size();
    }

    public int getColumnCount() {
        return 2;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Dosen k = dosen.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return k.getId_dosen();
            case 1:
                return k.getNama_dosen();
            default:
                return "";
        }
    }

    @Override
        public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Id Dosen";
            case 1:
                return "Nama Dosen";
            default:
                return "";
        }
    }
}
